package com.sanjiahantang.youjiaclient.module.goods.adapters;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.sanjiahantang.youjiaclient.R;
import com.sanjiahantang.youjiaclient.module.common.holders.CommonHolder;
import com.sanjiahantang.youjiaclient.module.goods.beans.GoodsAttrBean;

import java.util.ArrayList;
import java.util.List;

import static com.sanjiahantang.youjiaclient.config.StaticValue.HOLDER_TYPE_GOODS_ATTR_COUNT;
import static com.sanjiahantang.youjiaclient.config.StaticValue.HOLDER_TYPE_GOODS_ATTR_PROPERTY;

/**
 * Created by zy on 2017/10/24.
 */

public class GoodsAttrPropertyAdapter extends RecyclerView.Adapter {


    private Context context;
    private LayoutInflater inflater;
    private GoodsAttrBean.Data data;
    private List<Integer> typeList;

    public GoodsAttrPropertyAdapter(Context context, GoodsAttrBean.Data data){
        this.context = context;
        this.data = data;
        this.inflater = LayoutInflater.from(context);

        typeList = new ArrayList<>();
        if (data != null && data.getPropertyMap() != null){
            for (int i = 0,max = data.getPropertyMap().size(); i < max; i++){
                typeList.add(HOLDER_TYPE_GOODS_ATTR_PROPERTY);
            }
        }
        typeList.add(HOLDER_TYPE_GOODS_ATTR_COUNT);
    }



    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType){
            case HOLDER_TYPE_GOODS_ATTR_PROPERTY:
                return new CommonHolder((Activity) context,inflater.inflate(R.layout.item_goods_scale_property,null),HOLDER_TYPE_GOODS_ATTR_PROPERTY,null);
            case HOLDER_TYPE_GOODS_ATTR_COUNT:
                return new CommonHolder((Activity) context,inflater.inflate(R.layout.item_goods_scale_count,null),HOLDER_TYPE_GOODS_ATTR_COUNT,null);
        }
        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        switch (typeList.get(position)){
            case HOLDER_TYPE_GOODS_ATTR_PROPERTY:
                break;
            case HOLDER_TYPE_GOODS_ATTR_COUNT:
                break;
        }
    }

    @Override
    public int getItemViewType(int position) {
        return typeList.get(position);
    }

    @Override
    public int getItemCount() {
        return typeList.size();
    }
}
